package com.zhiwei.codesecurity.service.schedulejob;

import com.zhiwei.codesecurity.entity.ScheduleJob;

import java.util.List;

public interface ScheduleJobService {

    /**
     * 初始化定时任务:系统定时任务
     */
    public void initScheduleJobSystem();

    /**
     * 初始化定时任务：工作定时任务
     */
    public void initScheduleJob();


    /**
     * 开始一个定时任务
     * @param scheduleJob
     */
    public void StartScheduleJob(ScheduleJob scheduleJob);

    /**
     * 新增
     *
     * @param scheduleJob
     * @return
     */
    public Integer insert(ScheduleJob scheduleJob) throws Exception;

    /**
     * 直接修改 只能修改运行的时间，参数、同异步等无法修改
     *
     * @param scheduleJob
     */
    public void update(ScheduleJob scheduleJob) throws Exception;

    /**
     * 删除重新创建方式
     *
     * @param scheduleJob
     */
    public void delUpdate(ScheduleJob scheduleJob) throws Exception;

    /**
     * 删除
     *
     * @param scheduleJobId
     */
    public void delete(Long scheduleJobId) throws Exception;

    /**
     * 运行一次任务
     *
     * @param scheduleJobId the schedule job id
     * @return
     */
    public void runOnce(Long scheduleJobId) throws Exception;

    /**
     * 暂停任务
     *
     * @param scheduleJobId the schedule job id
     * @return
     */
    public void pauseJob(Long scheduleJobId) throws Exception;

    /**
     * 恢复任务
     *
     * @param scheduleJobId the schedule job id
     * @return
     */
    public void resumeJob(Long scheduleJobId) throws Exception;

    /**
     * 获取任务对象
     *
     * @param scheduleJobId
     * @return
     */
    public ScheduleJob get(Long scheduleJobId) throws Exception;

    /**
     * 查询任务列表
     *
     * @param scheduleJob
     * @return
     */
    public List<ScheduleJob> queryList(ScheduleJob scheduleJob) throws Exception;

    /**
     * 获取运行中的任务列表
     *
     * @return
     */
    public List<ScheduleJob> queryExecutingJobList() throws Exception;


    /**
     * 获取Quartz中的所有定时任务
     * @return
     * @throws Exception
     */
    public List<ScheduleJob> queryQuartzJobList() throws Exception;


//    /**
//     * 根据条件获取任务列表
//     * @return
//     * @throws Exception
//     */
//    public List<ScheduleJobDO> queryJobListByExample(ScheduleJobDOCriteria example) throws Exception;

    /**
     * 是否存在该JOB
     * @return
     * @throws Exception
     */
    public boolean existsJobName(String jobName) throws Exception;
}
